package design;

public class Client {


    public static void main(String[] args) {
        IFactory factory = new FamilyA();
        factory.makeProductA().doA();
        factory.makeProductB().doB();
    }

    private interface IProductA{
        void doA();
    }

    private interface IProductB{
        void doB();
    }

    private static class ProductAInFamilyA implements IProductA{
        public void doA() {
            System.out.println("The productA is part of FamilyA");
        }
    }

    private static class ProductBInFamilyA implements IProductB{
        public void doB() {
            System.out.println("The productB is part of FamilyA");
        }
    }

    private static class ProductAInFamilyB implements IProductA{
        public void doA() {
            System.out.println("The productA is part of FamilyB");
        }
    }

    private static class ProductBInFamilyB implements IProductB{
        public void doB() {
            System.out.println("The productB is part of FamilyB");
        }
    }

    private interface IFactory{
        IProductA makeProductA();
        IProductB makeProductB();
    }

    private static class FamilyA implements IFactory{

        public IProductA makeProductA() {
            return new ProductAInFamilyA();
        }

        public IProductB makeProductB() {
            return new ProductBInFamilyA();
        }
    }

    private static class FamilyB implements IFactory{

        public IProductA makeProductA() {
            return new ProductAInFamilyB();
        }

        public IProductB makeProductB() {
            return new ProductBInFamilyB();
        }
    }



}
